package com.gxa.hystrix.controller;

import com.gxa.hystrix.pojo.YaoFang;
import com.gxa.hystrix.service.YaoFangService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author thinknovo
 * @version 1.0
 * @description CheckController.java
 * @date 2021/3/11 9:30
 */
@RestController
@RequestMapping(value = "yaoFang", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class YaoFangController {
    @Resource
    private YaoFangService yaoFangService;

    /*
    这里类似于ribbon，提供一个对外访问的接口地址，
    然后根据serviceFeignByCheck接口来决定调用哪一个子模块服务和哪一个接口地址
     */
    @GetMapping("chaXunAll")
    public Map<String, Object> yaoFangChaXunAll() {
        return this.yaoFangService.yaoFangChaXunAll();
    }

    @PostMapping("gengXinById")
    public Map<String, Object> yaoFangGengXinById(@RequestBody YaoFang yaoFang) {
        return this.yaoFangService.yaoFangGengXinById(yaoFang);
    }

    @PostMapping("shanChuById")
    public Map<String, Object> yaoFangShanChuById(String id) {
        return this.yaoFangService.yaoFangShanChuById(id);
    }

    @PostMapping("chuShouById")
    public Map<String, Object> yaoFangChuShouById(@RequestBody YaoFang yaoFang) {
        return this.yaoFangService.yaoFangChuShouById(yaoFang);
    }
    @PostMapping("diaoRuById")
    public Map<String, Object> yaoFangDiaoRuById(int id, int diaoRuYaoFangShuLiang) {
        return this.yaoFangService.yaoFangDiaoRuById(id,diaoRuYaoFangShuLiang);
    }

    @PostMapping("xinZeng")
    public Map<String, Object> yaoFangXinZeng(@RequestBody YaoFang yaoFang) {
        return this.yaoFangService.yaoFangXinZeng(yaoFang);
    }

    @PostMapping("xiaZaiMuBan")
    public Map<String, Object> yaoFangXiaZaiMuBan( HttpServletResponse response, @RequestParam("ids") List<String> ids) throws IOException {
        return this.yaoFangService.yaoFangXiaZaiMuBan(response,ids);
    }


}
